﻿/******************************************************************************
 * Name         : EchoPacketHandler.cpp
 * Author       : 671643387
 * Date         : 2015年9月21日
 * Description  :
 *****************************************************************************/

#include <common/logger/Logger.hpp>
#include <common/player/Player.hpp>
#include <common/packet/PacketFactoryManager.hpp>
#include "EchoPacket.hpp"
using namespace sxr::common;

bool EchoPacketHandler::execute(EchoPacket* packet, Player* player)
{
//    getLogger()->log("echo: %s", packet->getMessage());

    PacketPtr newPacket = PacketFactoryManager::getMe()->createPacket(PACKET_ID_ECHO);
    if (newPacket)
    {
        EchoPacket* echoPacket = (EchoPacket*)newPacket.get();
        echoPacket->copy(packet->getMessage());

        player->sendPacket(newPacket);
        return true;
    }

    return false;
}
